package com.system.HRDepartment.dao;


import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;



import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.system.employee.entity.Employee;
import com.system.common.util.Sex;


@org.springframework.stereotype.Repository
	 public interface HRRepository extends PagingAndSortingRepository<Employee,Long>,JpaSpecificationExecutor<Employee>
		   {
		   	//1.通过解析方法名创建查询
		   	public Employee findByEmpId(Long id);  	



		   	@Modifying 
		   	@Query(value="update Employee emp set emp.empName = ?2,emp.sex = ?3,emp.birthday = ?4,emp.bornPlace = ?5,emp.address = ?6,emp.email = ?7,emp.phone = ?8,emp.education = ?9,emp.political = ?10,emp.ethnic = ?11,emp.idcard= ?12,emp.idcardImg = ?13 where emp.empId = ?1") 
		   	public int updateEmployee(Long id, String empName,Sex sex,Date birthday,String bornPlace,String address,String email,String phone,String education,String political,String ethnic,String idcard,String idcardImg);
		   	
		   	@Modifying 
		   	@Query(value="delete Employee emp where emp.empId  in (:ids)") 
		   	public int deleteEmployees(@Param("ids")Long[] ids);
		   	
		   	@Query(value="from Employee employee where employee.empName like ?1") 
		   	public Page<Employee> findAll(String empName ,Pageable pageable);

		   }
		   


